home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Wayzata's Best of Shareware PC/Windows 2
/
Wayzata's Best of Shareware 2.0 (Windows) (Wayzata Technology)(7112)(1994).bin
/
pc
/
dos
/
programg
/
zi_123
/
gosub.zsl
< prev
next >
Wrap
Text File
|
1992-08-19
|
2KB
|
58 lines
; *****************************************************************************
;
; GOSUB.ZSL
;
; Date : 07/05/92
; Author: Ben Morris
;
; ****************************************************************************
Int i ; Declare our counter integer
Label loop ; This is the loop label
i++ ; Add one to the integer
If i > 50 ; Is it > 50?
Dialog 50, 0 ; If so, show this dialog.....
@CHit any key to exit.
EndDialog
ExitScript ; And exit.
EndIf
Gosub writeit ; Jump to the place where we display
; the counter dialog.
Goto loop ; Once we've done that, loop back.
; *****************************************************************************
Label writeit ; This is the label that we GoSub to
; when we want to display the dialog.
Dialog 20, 1 ; Show the dialog....
@C%i%
EndDialog
Return ; 'Return' will jump us back to the
; line AFTER the last 'GoSub'.
#END
In the example above, a dialog will be displayed 50 times, with a counter
integer shown.
Z/Install maintains a 'Gosub Stack'. When 'Gosub' is called, the stack
increases by one and saves the current position in the script file. It then
jumps to the label specified with 'Gosub'.
When Z/Install sees the 'Return' command, it will jump back to the position
saved at the last 'Gosub' call. The stack decreases by one.
You can have a maximum of 500 Gosub calls (who would need that many?) before
issuing a 'Return' command.